layui.define(['form'], function (exports) {
    var $ = layui.jquery;
    var  layer = layui.layer;
    
    $('button[data-opt=btn_re],button[data-opt=btn_fw]').click(function(){
        var einfo=$(this).data('id');
        edit_dict(einfo);
    });
    function edit_dict(einfo) {
    	var index = parent.layer.getFrameIndex(window.name);
    	parent.layer.close(index);
        //iframe层
        parent.layer.open({
            type: 2,
            title: '回复/转发邮件',
            shadeClose: false,
            shade: 0.8,
            area: ['100%', '100%'],
            full:true,
            content: '?t=email_edit&'+einfo
        }); 
       
    }
    $('button[data-opt=renew]').click(function(){
        var id=$(this).data('id');
        layer.confirm('确定恢复？',function(index){
            $.post("/srv/sdo.php", {tpl:"renew_email_single",id:id}, function (d, e) {  
                if(d=="ok"){
                    parent.location.reload();
                    parent.layer.close(index);
                }
            });
        });
    });
    $('button[data-opt=del]').click(function(){
        var id=$(this).data('id');
        layer.confirm('确定删除？',function(index){
        	var tpl=($("#emailbox").val()=='lj')?"cdel_email_single":"del_email_single";
            $.post("/srv/sdo.php", {tpl:tpl,id:id}, function (d, e) {  
                if(d=="ok"){
                    parent.location.reload();
                    parent.layer.close(index);
                }
            });
        });
    });
    exports('email_view', {});
});